import poker.Brand;
import poker.Poker;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class Test {
    public static void swap(List<Brand> brands,int i,int index) {
        Brand tmp = brands.get(i);
        brands.set(i,brands.get(index));
        brands.set(index,tmp);
    }
    public static void wash(List<Brand> brands) {
        int len = brands.size();
        for (int i = len-1; i > 0; i--) {
            Random random = new Random();
            int index = random.nextInt(i);//生成到 0 到 i-1 的随机数
            //交换
            swap(brands,i,index);
        }
    }
    public static void main(String[] args) {
        //生成一副牌
        Poker poker = new Poker();
        List<Brand> brands = poker.initialization();
        System.out.println(brands);
        System.out.println("-------------------------------------------------------------");
        //洗牌
        wash(brands);
        System.out.println(brands);
        System.out.println("-------------------------------------------------------------");
        //三个人抓牌
        ArrayList<Brand> one = new ArrayList<>();
        ArrayList<Brand> two = new ArrayList<>();
        ArrayList<Brand> three = new ArrayList<>();

        List<ArrayList<Brand>> people = new ArrayList<>();
        people.add(one);
        people.add(two);
        people.add(three);
        
        //一人18张牌
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 18; j++) {
                ArrayList<Brand> tmp = people.get(i);
                Brand ret =  brands.remove(0);
                tmp.add(ret);
            }
        }

        System.out.println("玩家1 "+people.get(0));
        System.out.println("玩家2 "+people.get(1));
        System.out.println("玩家3 "+people.get(2));
    }
}
